package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.common.query.TravelQueryObject;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/travel")
public class TravelController {

    @Reference
    private ITravelService travelService;

    @RequestMapping("list")
    public String list(@ModelAttribute("qo") TravelQueryObject qo, Model model){
        PageInfo pageInfo = travelService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        return "travel/list";
    }
    //获取游记内容
    @RequestMapping("getTravelContent")
    @ResponseBody
    public Object getTravelContent(Long id){

        return travelService.getContent(id);
    }
    //修改状态
    @RequestMapping("updateState")
    @ResponseBody
    public AjaxResult updateState(Integer state, Long id){
            travelService.updateState(state,id);
        return new AjaxResult();
    }


}
